package com.hk.employeemanagementsystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hk.employeemanagementsystem.entity.DepartmentEntity;
import com.hk.employeemanagementsystem.mapper.DepartmentEntityMapper;
import com.hk.employeemanagementsystem.service.DepartmentEntityService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author by 何坤
 * @Classname DepartmentEntityServiceImpl
 * @Description TODO
 * @Date 2020/2/7 17:47
 */
@Service
@Transactional
public class DepartmentEntityServiceImpl extends ServiceImpl<DepartmentEntityMapper, DepartmentEntity> implements DepartmentEntityService {

    @Resource
    private DepartmentEntityMapper departmentEntityMapper;

    @Override
    public List<DepartmentEntity> getDepartment() {
        return departmentEntityMapper.getDepartment();
    }

    @Override
    public int addDepartment(DepartmentEntity departmentEntity) {
        departmentEntity.setEnabled(true);
        departmentEntityMapper.addDepartment(departmentEntity);
        return departmentEntity.getResult();
    }

    @Override
    public int deleteDepartment(Integer id) {
        DepartmentEntity departmentEntity = new DepartmentEntity();
        departmentEntity.setId(id);
        departmentEntityMapper.deleteDepartment(departmentEntity);
        return departmentEntity.getResult();
    }
}
